package com.springinaction.springidol;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class Instrumentalist implements Performer, InitializingBean, DisposableBean {

	private String song;
	private Instrument instrument;
	
	public Instrumentalist() {

	}
	
	public void init(){
		System.out.println("Init...");
	}
	
	public void finish(){
		System.out.println("Destroy...");
	}
	
	public void perform() throws PerformanceException {
		System.out.print("Playing " + song + " : ");
		instrument.play();
	}

	public void setSong(String song) {
		this.song = song;
	}
	
	public void setInstrument(Instrument instrument) {
		this.instrument = instrument;
	}
	
	public void afterPropertiesSet() throws Exception {
		instrument.tune();
	}

	public void destroy() throws Exception {
		instrument.clean();
	}
}